home *** CD-ROM | disk | FTP | other *** search
- /*
- ** WBScreen.c
- **
- ** Open or close the Workbench. Can also make another screen the default
- ** public screen.
- */
-
-
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/graphics.h>
- #include <proto/intuition.h>
- #include <string.h>
-
-
-
- UBYTE *Version = { "$VER: WBScreen 2.10 (24.08.97)" };
-
-
-
- main( int argc, char *argv[] )
- {
- char *ptr, **ttypes;
- ULONG secs;
-
-
- if ( IntuitionBase = ( struct IntuitionBase * )
- OpenLibrary( "intuition.library", 37L ))
- {
- if ( ttypes = ArgArrayInit( argc, argv ) )
- {
- ULONG ticks = GfxBase->DisplayFlags & PAL ? 50 : 60;
-
-
- ptr = ArgString( ttypes, "CLOSE", 0 );
-
- if ( ptr )
- CloseWorkBench();
-
-
- ptr = ArgString( ttypes, "OPEN", 0 );
-
- if ( ptr )
- OpenWorkBench();
-
-
- secs = ticks * ( ArgInt( ttypes, "DELAY", 0 ));
-
- if ( secs )
- Delay( secs ); // Wait before trying to find the screen.
-
-
- ptr = ArgString( ttypes, "DEFAULT", 0 );
-
- if ( ptr ) // If a pub screen name is specified
- { // we'll make that one the default.
- struct Screen *scr; // If AUTO is specified, we'll make
- // the frontmost screen the default.
-
- if ( stricmp( ptr, "AUTO" ) == NULL )
- {
- struct List *psList;
- struct PubScreenNode *psNode;
- ULONG lock;
-
- lock = LockIBase( NULL ); // Get a ptr to first scr.
-
- scr = IntuitionBase->FirstScreen;
-
- UnlockIBase( lock );
-
-
- psList = LockPubScreenList();
-
- psNode = ( struct PubScreenNode * ) psList->lh_Head;
-
- while ( psNode )
- {
- if ( scr == psNode->psn_Screen )
- {
- ptr = psNode->psn_Node.ln_Name;
-
- break; // Find the pub screen name
- } // of this frontmost screen.
-
- psNode = ( struct PubScreenNode * )
- psNode->psn_Node.ln_Succ;
- }
-
- UnlockPubScreenList();
- }
-
-
- if ( scr = LockPubScreen( ptr ))
- {
- SetDefaultPubScreen( ptr );
-
- SetPubScreenModes( POPPUBSCREEN | SHANGHAI );
-
- UnlockPubScreen( NULL, scr );
- }
- }
-
- ArgArrayDone();
- }
-
- CloseLibrary( ( struct Library * ) IntuitionBase );
- }
- }
-